import QtQuick 2.15
import QtQml 2.0
import QtQuick.Controls 2.15
import QtQuick.Window 2.2
import QtQuick.Layouts 1.0
import Log 1.0

Rectangle {
    id: mainWindow
    implicitWidth: 600
    implicitHeight: 480
    color: "white"

    Connections {
        target: mainManager
        function onTestSignals(data) {
            contentData.text = data
        }
    }

    Connections {
        target: view
        function onSignalQuit() {
            Qt.quit()
        }
    }

    ColumnLayout {
        anchors.fill: parent
        anchors.topMargin: 14
        anchors.bottomMargin: 14

        Text {
            id: infoText
            text: "这是主模块的界面"
            color: "#3986FF"
            font.pixelSize: 15
            horizontalAlignment: Text.AlignHCenter
            wrapMode: Text.WordWrap
            Layout.fillWidth: true
            Layout.leftMargin: 20
            Layout.rightMargin: 20
        }

        RowLayout {
            Layout.fillWidth: true
            Layout.topMargin: 10
            Layout.leftMargin: 10
            Layout.rightMargin: 10
            spacing: 10

            Text {
                id: title
                width: 120
                color: "#3986FF"
                text: "input data: "
                font.pixelSize: 14
            }

            CusTextField {
                id: content
                color: "#3986FF"
                Layout.fillWidth: true
                implicitHeight: 28
            }

            CusSolidBtn {
                id: subBtn
                implicitWidth: 120
                implicitHeight: 30
                Layout.alignment: Qt.AlignHCenter
                _text: "send"
                onClicked: {
                    mainManager.doTestPostMessage(content.text)
                }
            }
        }

        RowLayout {
            Layout.fillWidth: true
            Layout.topMargin: 0
            Text {
                id: contentTitle
                color: "#3986FF"
                text: "Data from helloword: "
                font.pixelSize: 14
            }

            Text {
                id: contentData
                text: ""
                color: "#3986FF"
                font.pixelSize: 14
            }

            Item {
                Layout.fillWidth: true
            }
        }

        Item {
            Layout.fillHeight: true
        }
    }
}
